﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" CodeFile="Add_Edit.aspx.cs" Inherits="admin_Category_Add_Edit" %>
<%@ Register TagName="MenuDialog" TagPrefix="uc" Src="~/admin/Dialog/MenuDialog.ascx" %>
<%@ Import Namespace="DalatCooking.Core.Helper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        jQuery(document).ready(function () {
            jQuery(".url").colorbox({ width: "650px", height: "600px", inline: true, href: "#menutype" });
            jQuery('#tabs').tabs();
        });

        function closeOverlay() {
            jQuery.colorbox.close();
        }
        function insertUrl(url) {
            jQuery("[id$='txtUrl']").val(url);
            closeOverlay();
        }
        function insertMenuType(url) {

            jQuery("#catalog").toggle("slow");

        }
       
           $(document).ready(function (e) {
               try {
                   $("body select").msDropDown();
               } catch (e) {
                   alert(e.message);
               }
           });
</script>   
    <div class="content-box-outer">
        <div class="content-box-right">
            <ul>
                <li class="content-box-selected"><a href="Add_Edit.aspx" class="new">Thêm danh mục</a></li>
                <li><a href="Default.aspx">Danh mục</a></li>
            </ul>
        </div>
        <div class="content-box-left">
            <h1>Thêm / Cập nhật Danh mục
              <a href="Add_Edit.aspx" class="addNew">Thêm chi tiết</a>
                </h1>
            <table class="tblForm largeForm" style="width: 100%; margin: 0;">
                <tr>
                    <td style="vertical-align: top; padding: 0 40px 0 0;">
                        <ul class="fl">
                            <li>
                                <label class="lbl" for="<%=txtName.ClientID %>">
                                    Tên Danh mục</label>
                                <asp:TextBox runat="server" ID="txtName" Width="400" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
                                    Display="Dynamic" ErrorMessage="Nhập tên Danh mục" />
                            </li>
                            <li>
                                <label class="lbl" for="<%=txtUrl.ClientID %>">
                                    Liên kết (Url)</label>
                                <asp:TextBox runat="server" ID="txtUrl" TabIndex="9" Width="400" />
                                <a href="#" class="url">Url</a> </li>
                            <li>
                                <label class="lbl" for="<%=txtDescription.ClientID %>">
                                    Mô tả</label>
                                <asp:TextBox runat="server" ID="txtDescription"  TextMode="MultiLine" Columns="50"
                                    Rows="3" Width="600" Height="80"  TabIndex="9" />
                            </li>
                            <li>
                                <label class="lbl" for="<%=txtSortIndex.ClientID %>">
                                    Sắp xếp</label>
                                <asp:TextBox runat="server" ID="txtSortIndex" Width="200" />
                            </li>
                            <li>
                                <label class="lbl">
                                    Tùy chọn</label>
                                <asp:CheckBox runat="server" ID="cbFrontPage" Text="Trang chủ" /><br />
                            </li>
                            <li>
                                <asp:CheckBox runat="server" ID="cbShowInList" Text="Hiển thị"
                                    Checked="true" />
                            </li>
                            <li>
                                <asp:CheckBox runat="server" ID="cbIsActive" Checked="true" Text="Kích hoạt" />
                            </li>
                        </ul>
                    </td>
                    <td class="secondaryForm" style="padding: 0; vertical-align: top;">
                        <ul class="fl">
                           

                             <li>
                                <label class="lbl">
                                    Hình ảnh</label>
                                <div class="rounded" style="overflow-y: auto; height: 160px; max-height: 160px; border: solid 1px #dcdcdc; padding: 5px; margin: 0 0 5px; text-align: center">
                                    <img src="/uploads/images/noimage.png" width="160" height="160" runat="server" id="imgthumb"
                                        clientid="Static" alt="" />
                                </div>
                                <div>
                                    <asp:TextBox ID="txtPicture" runat="server" CssClass="txt200" Text="/uploads/images/noimage.png"></asp:TextBox>
                                    <span class="belowHelp">Hình đại diện</span>
                                </div>
                            </li>
                              <label class="lbl">
                                    Chọn danh mục cha</label>
                                <asp:DropDownList runat="server" ID="ddlMenuParent" Width="250" >
                                </asp:DropDownList>
                            <li>
                                <div style="">
                                    <label class="lbl" for="<%=txtCategory.ClientID %>" style="margin-bottom: 5px; display: block;">
                                        Thêm nhanh Nhóm Category</label>
                                    <asp:TextBox runat="server" ID="txtCategory" ValidationGroup="category" Width="150" />
                                    <asp:Button runat="server" ID="btnCategory" Text="Thêm" ValidationGroup="category"
                                        CssClass="btn" Style="min-width: 0px; margin: 0;" OnClick="btnCategory_Click" />
                                    <asp:CustomValidator runat="Server" ID="valExist" ValidationGroup="category" ControlToValidate="txtCategory"
                                        ErrorMessage="Chuyên mục đã tồn tại" Display="dynamic" />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtCategory"
                                        ErrorMessage="Được yêu cầu" ValidationGroup="category" Display="Dynamic" />
                                </div>
                            </li>
                          
                            <li>
                                <label class="lbl" for="<%=txtKeyword.ClientID %>">
                                    Mô tả ngắn</label>
                                <asp:TextBox runat="server" ID="txtKeyword" TextMode="MultiLine" Rows="5" />
                            </li>

                        </ul>
                    </td>
                </tr>
            </table>
            <div class="action_buttons">
                <asp:Button ID="btnSave" Text="Lưu" CssClass="btn primary"
                    runat="server" OnClick="btnSave_Click" />
                hoặc
                <% if (!string.IsNullOrEmpty(Request.QueryString["MenuID"]))
                   { %>
                <a href="Default.aspx" title="Go to page">Quay lại</a>
                <%}
                   else
                   {%>
                <a href="Default.aspx" title="Cancel">Hủy</a>
                <%} %>
            </div>
        </div>
    </div>
    <div style="display: none">
        <uc:MenuDialog ID="menuDlg" runat="server" />

    </div>
      <script type="text/javascript">
          $(document).ready(function () {
              var thumb = jQuery("img#<%=imgthumb.ClientID %>");
            var txtPicture = jQuery("#<%=txtPicture.ClientID %>");
            txtPicture.blur(function () {
                thumb.attr('src', txtPicture.val());
            });
        });
    </script>
  <script type="text/javascript">    
      jQuery(document).ready(function () {
          var thumb = jQuery("img#<%=imgthumb.ClientID %>");
            var txtPicture = jQuery("#<%=txtPicture.ClientID %>");
          new AjaxUpload(thumb, {

                action: '/ImageUpload.axd',
                name: 'myFile',
                onSubmit: function (file, extension) {
                    if (!(extension && /^(jpg|png|jpeg|gif|bmp|JPG|PNG|JPEG|BMP|GIF)$/.test(extension))) {

                        alert('Only JPG, PNG or GIF files are allowed');
                        return false;
                    }

                    thumb.attr('src', '/uploads/images/bigoading.gif');

                    txtPicture.val('Loading...');
                    txtPicture.attr('disabled', true);
                    this.disable();

                },
                onComplete: function (file, response) {
                    thumb.load(function () {

                        thumb.unbind();

                    });
                    txtPicture.attr('disabled', false);
                    var resp = response;
                    resp = jQuery(resp).html();
                    thumb.attr('src', resp);
                    this.enable();

                    txtPicture.val(resp);

                }
            });
        });
    </script>
</asp:Content>


